package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.dg.DgRefundRequest;
import com.trhui.mallbook.domain.request.hf.HfRefundRequest;
import com.trhui.mallbook.domain.request.yb.YbRefundRequest;
import com.trhui.mallbook.domain.response.dg.DgRefundResponse;
import com.trhui.mallbook.domain.response.hf.HfRefundResponse;
import com.trhui.mallbook.domain.response.yb.YbRefundResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * @author huangh
 * @version 1.0
 * @description 退款接口
 * @date 2023/08/17 0017 14:50
 */

public class RefundClient extends AbstractClient {

    /**
     * 汇付-退款
     * 
     * @param request
     * @return
     */
    public static BaseResponse<HfRefundResponse> hfRefund(HfRefundRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.REFUND)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfRefundResponse.class);
    }

    /**
     * 易宝-退款
     * 
     * @param request
     * @return
     */
    public static BaseResponse<YbRefundResponse> ybRefund(YbRefundRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.REFUND)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(reqApiRequest, YbRefundResponse.class);
    }

    /**
     * 斗拱-退款
     * 
     * @param request
     * @return
     */
    public static BaseResponse<DgRefundResponse> dgRefund(DgRefundRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.REFUND)
                .channelType(ChannelTypeEnum.DG)
                .build();
        return post(reqApiRequest, DgRefundResponse.class);
    }
}
